<html>
<head>
<title>管理系统</title>
<meta http-equiv=Content-Type content=text/html;charset=utf-8>
<#include "../inc/commonJs.html">
<script language="JavaScript">
var windowparam = '', grid;
var col = [[  
            {field:'logid',title: 'ID',align: 'center',width: '40'},  
            {field:'name',title: '日志名称',align: 'center',width: '200'},
            {field:'taskName',title: '所属任务',align: 'center',width: '200'},
            {field:'fromUserName',title: '上级操作人',align: 'center',width: '70'},
            {field:'dt',title: '时间',align: 'center',width: '150'},
            {field:'zt',title: '状态',align: 'center',width: '80',
            	formatter: function(value,rowdata,index){
            		var str =''; 
            		if(value == 0){
            			str	= '待签收';
            		}else if(value == 1){
            			str	+= '进行中';
            		}else if(value == 2){
            			str	+= '完成';
            		}
					return str;
				}
            },
            {field:'demo',title: '说明',align: 'center',width: '260'}
        ]];
//页面加载  
$(function(){  
	//待签收
     $('#todoTaskgrid').datagrid({  
         url:'listMyTaskLog.do',  
         loadMsg:'数据加载中请稍后……',  
         pagination: true,  
         rownumbers: true,  
         striped: true,  
         singleSelect : true,  
         pageSize: [${syscfg.pageSize!10}],
         pageList: [${syscfg.pageList!10}],
         queryParams: {zt: '0'},   
         columns: col,
         toolbar : ['-',{
			id : 'btnshow',
			text : '查看任务',
			iconCls : 'icon-search',
			handler : function() {
				showTasklog($('#todoTaskgrid'));
			}
		},'-',{
			id : 'btndel',
			text : '签收',
			iconCls : 'icon-ok',
			handler : function() {
				receive(1,$('#todoTaskgrid'),$('#doingTaskgrid'));
			}
		},{
			id : 'btndel',
			text : '退回',
			iconCls : 'icon-cancel',
			handler : function() {
				receive(0,$('#todoTaskgrid'));
			}
		},'-'],
		onDblClickCell: function(rowIndex,rowData){
			showTasklog($('#todoTaskgrid'));
		}
    });
	// 进行中
    $('#doingTaskgrid').datagrid({  
        url:'listMyTaskLog.do',  
        loadMsg:'数据加载中请稍后……',  
        pagination: true,  
        rownumbers: true,  
        striped: true,  
        singleSelect : true,  
        pageSize: [${syscfg.pageSize!10}],
        pageList: [${syscfg.pageList!10}],
        queryParams: {zt: '1'},        
        columns: col,
         toolbar: ['-',{
			id : 'btnshow',
			text : '查看任务',
			iconCls : 'icon-search',
			handler : function() {
				showTasklog($('#doingTaskgrid'));
			}
		},'-',{
			id : 'btnedit',
			text : '完成',
			iconCls : 'icon-ok',
			handler : function() {
				receive(2,$('#doingTaskgrid'),$('#projectgrid'));
			}
		},'-'],
		onDblClickCell: function(rowIndex,rowData){
			showTasklog($('#doingTaskgrid'));
		}
     });
     // 已经完成
     grid = $('#projectgrid').datagrid({  
         url:'listMyTaskLog.do',  
         loadMsg:'数据加载中请稍后……',  
         pagination: true,  
         rownumbers: true,  
         striped: true,  
         singleSelect : true,  
         pageSize: [${syscfg.pageSize!10}],
         pageList: [${syscfg.pageList!10}],
         queryParams: {zt: '2'},   
         columns: col,
         toolbar: '#toolbar', 
		 onDblClickCell: function(rowIndex,rowData){
			showTasklog($('#projectgrid'));
		 }
     });
     //
     $("#tree").tree({
            method: "post",
            lines: true,
            url: "listProjectForTree.do",
            dataPlain: true,       //该属性用以启用当前 easyui-tree 控件对平滑数据格式的支持
            toggleOnClick: false,
            enableContextMenu: false,
            onClick: function(node){
            	var params = {};
            	windowparam = node.id;
				params['projectId'] = node.id;
				$('#projectgrid').datagrid('reload',params); 
			}
     });
});  
	function showTasklog(grid) {
		var selected = grid.datagrid('getSelected');
		if(!selected){
			top.noselectedalert();
			return;
		}
		var url = '${request.contextPath}/xadmin/work/taskLogManage.do?taskid='+selected.taskid;
		var ah = document.body.clientHeight;
		var aw = document.body.scrollWidth;
		top.modalwindow(url,'',{width:aw,height:ah,title:'任务日志',
	    	buttons:[top.btn_close]   
		});
	 }		
	//
	function receive(zt,_obj,nextobj){
		var selected = _obj.datagrid('getSelected');
		if(!selected){
			top.noselectedalert();
			return;
		}
		var worker = selected.userid;
		var taskid = selected.taskid;
		if(worker != ${userInfo.userid!}){
			top.messageralert("你不是该任务日志执行人，无权限修改状态！");
			return;
		}
		var url = '${request.contextPath}/xadmin/work/mytaskWindow.do?logid='+selected.logid+'&zt='+zt;
		var mwin = top.modalwindow(url,_obj,{width:450, height:260,
		    title:'修改任务信息',
		    buttons:[{
				text:'保存',
				iconCls:"icon-save",
				handler:function(){
					mwin.find('iframe')[0].contentWindow.saveObj(selected.logid,zt,nextobj);
				}
			},top.btn_close]   
		});
	}
	//刷新
	function doReload(){
		$('#toolbar input').val('');
		grid.datagrid('reload',{});
	}
	//搜索
	function doSearch(){
		var params = {};
		params['zt'] = 2;//完成
		if($('#dt').datebox('getValue')){
			params['dt'] = $('#dt').datebox('getValue');
		}
		if($('#demo').datebox('getValue')){
			params['demo'] = $('#demo').datebox('getValue');
		}
		grid.datagrid('reload',params);
	}
</script>

</head>
<body>
<div class="easyui-tabs" data-options="fit:true">   
    <div title="待签收" data-options="iconCls:'icon-help'">   
        <table id="todoTaskgrid" data-options="fit:true,border:false"></table> 
    </div>   
    <div title="进行中" data-options="iconCls:'icon-reload'" >   
       <table id="doingTaskgrid" data-options="fit:true,border:false"></table>
    </div>   
    <div title="已完成" data-options="iconCls:'icon-print',closable:false">   
    	<div class="easyui-layout" data-options="fit:true">
	        <div data-options="region:'west',iconCls:'icon-mini-add',title:'按项目查找',split:true,collapsed:true" style="width:180px;">
				<div class="easyui-panel" data-options='fit:true,border:false'> 
					<ul id="tree"></ul>
				</div>
			</div>   
			<div data-options="region:'center'">
				<table id="projectgrid" data-options="fit:true,border:false"></table>
			</div> 
		</div> 
    </div>   
</div> 
<div id="toolbar" style="display: none;">
<table border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td valign="center">
	&nbsp;开始日期：	<input class="easyui-datebox" type="text" id="dt" name="dt" maxlength="30" style="width:150px;">
	</td>
	<td valign="center">
	&nbsp;结束日期：<input class="easyui-datebox" type="text" id="demo" name="demo" maxlength="30" style="width:150px;">
	</td>
	<td valign="center">	
	<a href="javascript:doSearch();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">搜索</a>
	</td>
	<td valign="center">
	<td valign="center"><div class="datagrid-btn-separator"></div></td>
	</td>
	<td valign="center">
	<a href="javascript:doReload();" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true">刷新</a>
	</td>
	<td valign="center"><div class="datagrid-btn-separator"></div></td>
	<td valign="center">	
	<a href="javascript:showTasklog($('#projectgrid'));" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">查看任务</a>
	</td>
	<td valign="center"><div class="datagrid-btn-separator"></div></td>
</tr>
</table>
</div>
</body>
</html>